package com.zzq.service.impl;

import com.zzq.domain.dto.SmileCouponRuleDTO;
import com.zzq.domain.entity.SmileCoupon;
import com.zzq.domain.entity.SmileCouponRule;
import com.zzq.domain.search.CouponRuleSerachParamet;
import com.zzq.result.SmileResult;
import com.zzq.service.CouponRuleAdminService;
import com.zzq.service.SmileCouponRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class CouponRuleAdminServiceImpl implements CouponRuleAdminService {

    @Autowired
    SmileCouponRuleService couponRuleService;

    @Override
    @Transactional
    public SmileResult addCouponRule(SmileCouponRule couponRule) {
        couponRuleService.save(couponRule);
        return SmileResult.sucess("添加成功");
    }

    @Override
    public SmileResult getCouponRuleDTOList(CouponRuleSerachParamet serachParamet) {
        List<SmileCouponRuleDTO> couponRuleDTOList = couponRuleService.getCouponRuleDTOList(serachParamet);
        return SmileResult.sucess("成功",couponRuleDTOList);
    }

    @Override
    @Transactional
    public SmileResult updCouponRule(SmileCouponRule couponRule) {
        couponRuleService.updateById(couponRule);
        return SmileResult.sucess("成功");
    }

    @Override
    @Transactional
    public SmileResult delCouponRule(Long couponRuleId) {
        couponRuleService.removeById(couponRuleId);
        return SmileResult.sucess("成功");
    }
}
